package com.testmanager.testmananger.shuiyou.strCompare.mapper;

import com.testmanager.testmananger.shuiyou.strCompare.domain.*;
import com.testmanager.testmananger.shuiyou.strCompare.dto.CompareScriptDto;
import com.testmanager.testmananger.shuiyou.strCompare.dto.SyCompareTaskDto;
import com.testmanager.testmananger.shuiyou.strCompare.dto.SyProjectDto;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
public class CompareTaskMapper {

    public static SyCompareTaskEntity toTaskEntity(SyCompareTaskDto taskDto){
        log.info("toTaskEntity,SyCompareTaskDto:{}",taskDto);

        return new SyCompareTaskEntity().setId(taskDto.getId())
                .setAutoflag(taskDto.getAutoflag())
                .setName(taskDto.getName())
                .setDestDbId(taskDto.getDestDb().getDbno())
                .setSrcDbID(taskDto.getSrcDb().getDbno())
                .setProjectId(taskDto.getProject().getId())
                .setScriptId(taskDto.getScript().getScriptno())
                .setStatus(taskDto.getStatus())
                .setLastExecuteTime(taskDto.getLastExecuteTime())
                .setScriptName(taskDto.getScriptName())
                .setTaskno(taskDto.getTaskno());

    }

    public static SyCompareTaskDto toSyCompareTaskDto(SyCompareTaskEntity taskEntity, CompareScriptDto scriptEntity, SyProjectDto projectEntity, SyDbManagerEntity srcDb, SyDbManagerEntity destDb, List<SyTaskVariableValueEntity> variables){

        return new SyCompareTaskDto()
                .setId(taskEntity.getId())
                .setAutoflag(taskEntity.getAutoflag())
                .setName(taskEntity.getName())
                .setStatus(taskEntity.getStatus())
                .setProject(projectEntity)
                .setScript(scriptEntity)
                .setSrcDb(srcDb)
                .setDestDb(destDb)
                .setVariables(variables)
                .setResult(taskEntity.getResult())
                .setLastExecuteTime(taskEntity.getLastExecuteTime())
                .setScriptName(taskEntity.getScriptName())
                .setTaskno(taskEntity.getTaskno());
    }

}
